/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package MedicalDocumentation;

import EntityClass.DischargeSummary;
import EntityClass.Transfer;
import EntityClass.mCase;
import Exception.CaseException;
import Interface.DischargeAndTransferBean1Remote;
import javax.ejb.Stateful;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Ben
 */
@Stateful
public class DischargeAndTransferBean1 implements DischargeAndTransferBean1Remote {

   @PersistenceContext()
    EntityManager em;
    DischargeSummary dischargeSummary;
    Transfer transfer;
     mCase mcase;
    
    public DischargeAndTransferBean1(){}
     
      //lack of query sentence to database?
    /**
     *
     * @param caseId
     * @param diagnosis
     * @param findings
     * @param recommendation
     * @param patientState
     * @param medicalProcedure
     * @throws CaseException
     * 
     */
    
    


    public mCase getCaseInfo(Long caseId)throws CaseException{
          mcase =em.find(mCase.class, new Long(caseId));
        if (mcase==null){
            em.flush();
            throw new CaseException("Case does not exsit");
        }
        return mcase;
    }
 
    public void generateDischargeSummary( String diagnosis, String findings, 
              String recommendation, String patientState, String medicalProcedure) {
        dischargeSummary= new DischargeSummary();
        dischargeSummary.create(diagnosis, findings, recommendation, patientState,
             medicalProcedure);
      mcase.setDischargeSummary(dischargeSummary);
      em.persist(mcase);
    }
    
    public DischargeSummary getDischargeSummary(){return null;}
    public DischargeSummary updateDischargeSummary(){return null;}
    public void deleteDischargeSummary(){}

    
      //lack of query sentence to database?
    public void recodeTransfer(String referDoctor, String reason){
        transfer=new Transfer();
        transfer.create(referDoctor,reason);
        mcase.setTransfer(transfer);
        em.persist(mcase);
    }

    public Transfer getTransfer(){return null;}
    public Transfer updateTransfer(){return null;}
    public void deleteTransfer(){}
   

}
